package cn.licoy.wdog.core.service.hospital.impl;

import cn.licoy.wdog.common.bean.ResponseCode;
import cn.licoy.wdog.common.exception.RequestException;
import cn.licoy.wdog.common.util.Encrypt;
import cn.licoy.wdog.core.dto.hospitalUser.TitleDto;
import cn.licoy.wdog.core.entity.hospital.Smscode;
import cn.licoy.wdog.core.entity.hospital.Title;
import cn.licoy.wdog.core.entity.system.SysUser;
import cn.licoy.wdog.core.mapper.hospital.SmscodeMapper;
import cn.licoy.wdog.core.mapper.hospital.TitleMapper;
import cn.licoy.wdog.core.service.hospital.SmscodeService;
import cn.licoy.wdog.core.service.hospital.TitleService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author Sunne
 * Create time 2018/6/22 13:50
 * @return null
 **/
@Service
@Transactional
public class TitleServiceImpl extends ServiceImpl<TitleMapper,Title> implements TitleService {
    @Override
    public void add(TitleDto dto) {
        if ("".equals(dto.getName())||dto.getName()==null){
            throw new RequestException(ResponseCode.FAIL);
        }
        try {
           Title title = new Title();
           title.setRemake("1");
           title.setCreateDate(new Date());
           title.setName(dto.getName());
           this.insert(title);
        }catch (Exception e){
            throw RequestException.fail("添加用户失败",e);
        }
    }
}
